<?php
/**
 * @copyright  For copyright and license information, read the COPYING.txt file.
 * @link       /COPYING.txt
 * @license    Academic Free License (AFL 3.0)
 * @package     default_default
 */

/** @var Mage_Adminhtml_Block_Sales_Order_Abstract $this */
?>
<?php $_order = $this->getOrder() ?>
<div>
    <div id="order-messages">
        <?php echo $this->getChildHtml('order_messages') ?>
    </div>
    <?php echo $this->getChildHtml('order_info') ?>
    <input type="hidden" name="order_id" value="<?php echo $_order->getId() ?>"/>
    <?php if ($_order->getIsVirtual()): ?>
    <div class="box-right">
    <?php else: ?>
    <div class="box-left">
    <?php endif ?>
        <!--Payment Method-->
        <div class="entry-edit">
            <div class="entry-edit-head">
                <h4 class="icon-head head-payment-method"><?php echo Mage::helper('sales')->__('Payment Information') ?></h4>
            </div>
            <fieldset>
                <?php echo $this->getPaymentHtml() ?>
                <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
                <?php if ($_order->getCouponCode()): ?>
                    <div><?php echo Mage::helper('sales')->__('Coupon code used: %s (%s)', $this->escapeHtml($_order->getCouponCode()), $this->escapeHtml($_order->getDiscountDescription())); ?></div>
                <?php endif; ?>
            </fieldset>
        </div>
    </div>
    <?php if (!$_order->getIsVirtual()): ?>
    <div class="box-right">
        <!--Shipping Method-->
        <div class="entry-edit">
            <div class="entry-edit-head">
                <h4 class="icon-head head-shipping-method"><?php echo Mage::helper('sales')->__('Shipping &amp; Handling Information') ?></h4>
            </div>
            <fieldset>
                <?php  if ($_order->getTracksCollection()->count()) : ?>
                <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->quoteEscape($this->__('Track Order')) ?>"><?php echo $this->__('Track Order') ?></a>
                <br/>
                    <?php foreach ($_order->getTracksCollection() as $_track): ?>
                        <div>
                            <?php $trackNumber = $_track->getNumber();?>
                            <strong><?php echo $_track->getTitle() ?></strong>
                            <span data-copy-text="<?php echo $trackNumber ?>"><?php echo $trackNumber ?></span>
                        </div> 
                    <?php endforeach; ?>
                <?php endif ?>
                <?php if ($_order->getShippingDescription()): ?>
                    <strong><?php echo $this->escapeHtml($_order->getShippingDescription()) ?></strong>

                    <?php if ($this->helper('tax')->displayShippingPriceIncludingTax()): ?>
                        <?php $_excl = $this->displayShippingPriceInclTax($_order); ?>
                    <?php else: ?>
                        <?php $_excl = $this->displayPriceAttribute('shipping_amount', false, ' '); ?>
                    <?php endif ?>
                    <?php $_incl = $this->displayShippingPriceInclTax($_order); ?>

                    <?php echo $_excl; ?>
                    <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
                        (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
                    <?php endif ?>
                <?php else: ?>
                    <?php echo $this->helper('sales')->__('No shipping information available'); ?>
                <?php endif ?>
            </fieldset>
        </div>
    </div>
    <?php endif ?>
    <div class="clear"></div>
    <?php echo $this->getGiftOptionsHtml() ?>
    <div class="clear"></div>
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
        </div>
    </div>
    <?php echo $this->getItemsHtml() ?>
    <div class="clear"></div>

    <div class="box-left">
        <div class="entry-edit">
            <div class="entry-edit-head">
                <h4><?php echo Mage::helper('sales')->__('Comments History') ?></h4>
            </div>
            <fieldset><?php echo $this->getChildHtml('order_history') ?></fieldset>
        </div>
    </div>
    <div class="box-right entry-edit">
        <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
        <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
    </div>
    <div class="clear"></div>
</div>

<?php echo $this->getChildHtml('popup_window');?>
<script type="text/javascript">
//<![CDATA[
    /**
     * Retrieve gift options tooltip content
     */
    function getGiftOptionsTooltipContent(itemId) {
        var contentLines = [];
        var headerLine = null;
        var contentLine = null;

        $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
            if (element.down(0)) {
                headerLine = element.down(0).innerHTML;
                contentLine = element.down(0).next().innerHTML;
                if (contentLine.length > 30) {
                    contentLine = contentLine.slice(0,30) + '...';
                }
                contentLines.push(headerLine + ' ' + contentLine);
            }
        });
        return contentLines.join('<br/>');
    }
    giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
//]]>
</script>
